//
//  NWDiscoverHeaderView.m
//  World
//
//  Created by lanou on 15/10/26.
//  Copyright © 2015年 小虫. All rights reserved.
//

#import "NWDiscoverHeaderView.h"
#import <UIImageView+WebCache.h>
@implementation NWDiscoverHeaderView

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        _HeaderimageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH,  SCREEN_HEIGHT / 4)];
    
        [self addSubview:_HeaderimageView];
        
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(65, SCREEN_HEIGHT / 4 + 10, SCREEN_WIDTH - 20, 40)];
       // _nameLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:22];
        _nameLabel.font = [UIFont systemFontOfSize:22];
        [self addSubview:_nameLabel];
        
        
        _userImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, SCREEN_HEIGHT / 4 + 60, 30, 30)];
        _userImage.layer.masksToBounds = YES;  // 把图片的修改打开
        [_userImage.layer setCornerRadius:15];

        [self addSubview:_userImage];
        
        _userNameLabel = [[UILabel alloc]initWithFrame:CGRectMake(45, SCREEN_HEIGHT / 4 + 60, 40, 20)];
        _userNameLabel.font = [UIFont systemFontOfSize:12];
        _userNameLabel.textColor = [UIColor grayColor];
      
        [self addSubview:_userNameLabel];
        
        _timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH - 100, SCREEN_HEIGHT / 4 + 60, 100, 20)];
        _timeLabel.textColor = [UIColor grayColor];
        _timeLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:_timeLabel];
        
        UIImageView *Loveimage = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Love.png"]];
        Loveimage.frame = CGRectMake(10, SCREEN_HEIGHT / 4 + 10, 40, 40);
        [self addSubview:Loveimage];
        
        
        _buyButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _buyButton.backgroundColor = [UIColor blackColor];
        [_buyButton setTitle:@"喜欢就买" forState:(UIControlStateNormal)];
        _buyButton.titleLabel.font = [UIFont systemFontOfSize:16];
        [_buyButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        _buyButton.frame = CGRectMake(SCREEN_WIDTH - 100,SCREEN_HEIGHT / 4 + 60, 80, 30);
        _buyButton.layer.masksToBounds = YES;
        [_buyButton.layer setCornerRadius:10];
        [self addSubview:_buyButton];
        
    }
    return self;
}

- (void)setDetailModle:(NWDiscoverDetail *)detailModle
{
    
    [_HeaderimageView sd_setImageWithURL:[NSURL URLWithString:detailModle.guide_image.url]];
    _nameLabel.text = detailModle.title;
    [_userImage sd_setImageWithURL:[NSURL URLWithString:detailModle.author.avatar]];
    _userNameLabel.text = detailModle.author.nickname;
    
    
}

@end
